insert overwrite table jms_dwd.dwd_sqs_leave_message_base_dt partition(dt)
select id
     , waybill_no
     , register_network_id
     , register_network_code
     , register_network_name
     , register_person_code
     , register_person_name
     , register_person_phone
     , receive_network_id
     , receive_network_code
     , receive_network_name
     , reply_content
     , file_url
     , is_reply
     , create_by
     , create_by_code
     , update_by_code
     , update_by
     , create_by_name
     , update_by_name
     , create_time
     , update_time
     , is_delete
     , country_id
     , is_enable
     , pick_network_code
     , pick_network_name
     , conversation_id
     , last_reply
     , leave_message_type
     , new_content
     , receiver_phone
     , latest_reply_time
     , second_type_name
     , receiver_name
     , to_date(update_time) as dt
from (
         select *,
                row_number() over (partition by id,waybill_no order by update_time desc) as rn
         from jms_ods.leave_message
         where dt between date_sub('{{ execution_date | cst_ds }}', 30) and '{{ execution_date | cst_ds }}'
     ) a
where a.rn = 1
distribute by dt,pmod(hash(rand()),6);